<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

if(0){?><script><?php }?>

Ext.define('Hydcrm.position.PositionModuleGrid', {
    extend: 'Ext.grid.Panel',
    requires: [
        'Ext.data.*',
        'Ext.grid.*',
        'Ext.tree.*',
        'Ext.form.*',
        'Ext.util.*',
        'Ext.selection.*',
        'Ext.ux.CheckColumn'
    ],
    initComponent: function() {  //alert(this.positionid);
        //this.positionid;             //外部传入
        this.PositionModuleModelStore = Ext.create('Ext.data.Store', {
            storeId: 'module',
            fields: ['group', 'checked', 'module', 'module_title', 'add', 'edit', 'delete', 'import', 'export'],
            sorters: ['group', 'checked', 'resource'],
            groupField: 'group',
            proxy: {
                type: 'ajax',
                url: Hydcrm.CONF.CONN_URL,
                extraParams: {
                    module: 'position',
                    action: 'get_position_module',
                    id: this.positionid
                },
                actionMethods: {
                    read: 'POST'
                },
                reader: {
                    type: 'json',
                    root: Hydcrm.CONF.JSON_READER_ROOT
                }
            },
            listeners:{
                groupchange:function(store,fet){
                    alert(store);
                }
            }//,
            //autoLoad: true
        });
        var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
            groupHeaderTpl: ' {name} ({rows.length} {[HydcrmLanguage.groupItems]}) ',
            enableNoGroups : false,
            enableGroupingMenu :false
        });
        Ext.QuickTips.init();
        Ext.apply(this, {
            collapsible: true,
            autoScroll : true,
            iconCls: 'icon-grid',
            frame: true,
            store: this.PositionModuleModelStore,
            width: '99%',
            height: 480,
            title: '可操作模块',
            features: [groupingFeature],
            
            plugins: [
                new Ext.grid.plugin.CellEditing({
                    clicksToEdit: 1
                })
            ],
            selType: 'cellmodel', //设置为单元格选择模式

            columns: [{
                    header: '选择',
                    width: 70,
                    align: 'center',
                    dataIndex: 'checked',
                    xtype: 'checkcolumn'
                }, {
                    text: '模块名称',
                    flex: 1,
                    width: 180,
                    dataIndex: 'module_title'
                }, {
                    text: '添加',
                    width: 60,
                    align: 'center',
                    dataIndex: 'add',
                    xtype: 'checkcolumn'
                }, {
                    text: '编辑',
                    width: 60,
                    align: 'center',
                    dataIndex: 'edit',
                    xtype: 'checkcolumn'
                }, {
                    header: '删除',
                    width: 60,
                    align: 'center',
                    dataIndex: 'delete',
                    xtype: 'checkcolumn',
                }, {
                    header: '导入',
                    width: 60,
                    align: 'center',
                    dataIndex: 'import',
                    xtype: 'checkcolumn',
                }, {
                    header: '导出',
                    width: 60,
                    align: 'center',
                    dataIndex: 'export',
                    xtype: 'checkcolumn'
                }//,this.ceshi()
                
                ]              
        });
 
        
        this.PositionModuleModelStore.load(function(records, operation, success) {
            Ext.Array.each(records,function(model){
                //alert(model.get('group'));
                //alert(model.get('checked'));
                //alert(model.get('add'));
                //alert(model.get('resource'));
                if(model.get('checked')=='aa'){
                    //alert('空');
                }
            });
        });
        this.callParent();
    },
    
    ceshi: function() {//权限控制 ceshi
        if(1){
            return{
                header: '删除',
                xtype: 'checkcolumn',
                width: 60,
                align: 'center',
                dataIndex: 'delete'
            };
        }else{
            return false;
        }      
    }
});

/* End of file group_resource_privilege_grid.php */
/* Location: ./system/modules/group/views/group_resource_privilege_grid.php */